﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Student_management
{
    public partial class frmInfo : Form
    {
        Connection db = new Connection();
        public frmInfo()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
            logo.ImageLocation = openFileDialog1.FileName;
        }

        private void luu_Click(object sender, EventArgs e)
        {
            if (Sua())
                MessageBox.Show("Thông tin trường thay đổi thành công !");
        }

        public bool Sua()
        {
            string[] param = { "@Ten", "@DiaChi", "@DT", "@Logo" };
            object[] value = { ten.Text, diachi.Text, dt.Text, logo.ImageLocation };
            string query = "Update ThongTin set Ten=@Ten, DiaChi=@DiaChi, DT=@DT, Logo=@Logo  where id='1'";
            return db.ExecuteNonQueryPara(query, param, value);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
            
        }

        private void Info_Load(object sender, EventArgs e)
        {
            DataTable a = new DataTable();
            a = db.getDS("Select * from ThongTin");
            ten.Text = a.Rows[0]["Ten"].ToString();
            diachi.Text = a.Rows[0]["DiaChi"].ToString();
            dt.Text = a.Rows[0]["DT"].ToString();
            logo.ImageLocation = a.Rows[0]["logo"].ToString();
        }
    }
}
